package com.ossjk.oa.advisory.service.impl;

import com.ossjk.core.util.CommonUtil;
import com.ossjk.oa.advisory.entity.Counterpart;
import com.ossjk.oa.advisory.entity.Counterpartfw;
import com.ossjk.oa.advisory.mapper.CounterpartMapper;
import com.ossjk.oa.advisory.service.ICounterpartService;
import com.ossjk.oa.advisory.service.ICounterpartfwService;
import com.baomidou.mybatisplus.mapper.SqlHelper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 学校对接人 服务实现类
 * </p>
 *
 * @author chair
 * @since 2019-02-14
 */
@Service
public class CounterpartServiceImpl extends ServiceImpl<CounterpartMapper, Counterpart> implements ICounterpartService {
	@Autowired
	private ICounterpartfwService iCounterpartfwService;
	@Autowired
	private ICounterpartService iCounterpartService;

	@Override
	public Page selectVoPage(Page page, Wrapper wrapper) {
		SqlHelper.fillWrapper(page, wrapper);
		page.setRecords(baseMapper.selectVoPage(page, wrapper));
		return page;
	}

	@Override
	public boolean insertRecords(Counterpart counterpart) {
		// TODO Auto-generated method stub
		if (!CommonUtil.isBlank(counterpart)) {
			iCounterpartService.insert(counterpart);
			Counterpartfw counterpartfw = new Counterpartfw();
			counterpartfw.setCid(counterpart.getId());
			counterpartfw.setEid(counterpart.getEid());
			iCounterpartfwService.insert(counterpartfw);
		}
		return true;
	}

	@Override
	public List selectVo(Wrapper wrapper) {
		// TODO Auto-generated method stub

		return baseMapper.selectVo(wrapper);
	}

}
